﻿//https://www.nowcoder.com/practice/8b3b95850edb4115918ecebdf1b4d222?tpId=13&tqId=11192&ru=/exam/oj

#include <algorithm>
class Solution {
public:
    int getHeight(TreeNode* root) {
        if (root == nullptr) return 0;
        return max(getHeight(root->left), getHeight(root->right)) + 1;
    }

    int getBalance(TreeNode* root) {
        if (root == nullptr) return 0;
        return getHeight(root->left) - getHeight(root->right);
    }

    bool IsBalanced_Solution(TreeNode* pRoot) {
        if (pRoot == nullptr) return true;
        int ret = getBalance(pRoot);
        if (abs(ret) > 1) return false;
        return IsBalanced_Solution(pRoot->left) && IsBalanced_Solution(pRoot->right);
    }
};


class Solution
{
public:
    bool IsBalanced_Solution(TreeNode* pRoot)
    {
        return dfs(pRoot) != -1;
    }
    int dfs(TreeNode* root) // 返回值不是 -1 的话，其余的返回值表⽰的是树⾼
    {
        if (root == nullptr) return 0;
        int left = dfs(root->left);
        if (left == -1) return -1; // 剪枝
        int right = dfs(root->right);
        if (right == -1) return -1;
        return abs(left - right) <= 1 ? max(left, right) + 1 : -1;
    }
};


//https://www.nowcoder.com/practice/a5a0b05f0505406ca837a3a76a5419b3?tpId=230&tqId=40416&ru=/exam/oj

#include <iostream>
using namespace std;
const int N = 110;
int n;
int dp[N][N];
int main()
{
    int x;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            cin >> x;
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + x;
        }
    }
    int ret = -127 * N;
    for (int x1 = 1; x1 <= n; x1++)
    {
        for (int y1 = 1; y1 <= n; y1++)
        {
            for (int x2 = x1; x2 <= n; x2++)
            {
                for (int y2 = y1; y2 <= n; y2++)
                {
                    ret = max(ret, dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 -
                        1] + dp[x1 - 1][y1 - 1]);
                }
            }
        }
    }
    cout << ret << endl;
    return 0;
}


//https://ac.nowcoder.com/acm/problem/230830

#include <iostream>
#include <string>
using namespace std;
int n;
string s;
int main()
{
    cin >> n >> s;
    int sum[2] = { 0 }; // 统计字符串中所有 0 和 1 的个数
    for (auto ch : s)
    {
        sum[ch - '0']++;
    }
    int left = 0, right = 0, ret = 0, half = n / 2;
    int count[2] = { 0 }; // 统计窗⼝内 0 和 1 的个数
    while (right < n - 1) // 细节问题
    {
        count[s[right] - '0']++;
        while (right - left + 1 > half)
        {
            count[s[left++] - '0']--;
        }
        if (right - left + 1 == half)
        {
            if (count[0] * 2 == sum[0] && count[1] * 2 == sum[1])
            {
                ret += 2;
            }
        }
        right++;
    }
    cout << ret << endl;
    return 0;
}